OPC-UA Embedded Server SDK  2.1.0
Read and Write Functions

Functions

void UAServer_Callback_read (uint32_t node_handle, UA_Value_type_t value_type, uint32_t max_array_length, uintptr_t read_context)
 
UA_Status_t UAServer_Perform_read (uintptr_t read_context, UA_Value_t data_value, int64_t source_timestamp, UA_Status_t status_code)
 
void UAServer_Callback_write (uint32_t node_handle, UA_Value_type_t value_type, UA_Status_t status_code, uint32_t max_array_length, uintptr_t write_context)
 
UA_Status_t UAServer_Perform_write (uintptr_t write_context, UA_Value_t data_value, int64_t *source_timestamp, bool_t completes_asynchronously, uint32_t *new_length_of_array)
 
void UAServer_Set_write_operation_level_result_code (uintptr_t write_context, UA_Status_t result_code)
 
void UAServer_Callback_monitored_item (uint32_t node_handle, uint32_t monitored_item_id, UA_Mon_Item_Callback_Operation_t operation, uint64_t sampling_interval_ms)
 

Detailed Description

Function Documentation

void UAServer_Callback_read ( uint32_t  node_handle,
UA_Value_type_t  value_type,
uint32_t  max_array_length,
uintptr_t  read_context 
)

Function provided by host to enable library to read values

The library requires the ability to read values from the host system in order to operate. This ability is provided by this function which must be implemented by the host system. This function is called by the library and the implemented function must call UA_Perform_read() in order to perform the actual read operation.

Parameters
[in]node_handleA unique identifier that the host can use to efficiently look up the value.
[in]value_typeIn order to keep the API lean, this function returns the variable to the library via a non type safe void pointer. The value_type parameter provides run-time type safety by specifying the data type the library expects for the value attribute of the node and allowing the host to verify this against the node handle provided by the library.
[in]max_array_lengthSimilar to the value_type parameter, the max_array_length parameter facilitates run-time type safety by specifying the max array length the library expects for the provided pointer allowing the host to verify this against the node handle provided by the library.
[in]read_contextA pointer to an opaque data structure providing context to the pending read operation. The host must pass this pointer to UA_Perform_read().
UA_Status_t UAServer_Perform_read ( uintptr_t  read_context,
UA_Value_t  data_value,
int64_t  source_timestamp,
UA_Status_t  status_code 
)

Performs a read operation

The host calls this function from UA_Read_callback() to perform a read on the requested node.

Parameters
[in]read_contextA pointer to an opaque data structure providing context to the pending read operation. The user must pass this pointer to UA_Perform_read().
[in]data_valueA pointer to the value required to be read by the library or 0 if the input parameters failed verification or the value is not readable. The value would not be readable if the host system's connection to the underlying data source was unavailable. In this case the host may decide to simply return the most recent cached value (with a corresponding old timestamp) or may return 0 in order to indicate that the data cannot be read.
[in]source_timestampEach time the host value is updated by the host, the host should timestamp the update. This timestamp is provided to the library via this parameter and communicated to the client in the DataValue structure.
[in]status_codeFor Data Access variable types the user must provide a data quality status code to inform the client as to the status of the data read. For base data variable calls this value is ignored by the library and the server returns Bad_NotReadable if the call provides a 0 data_value pointer. For Data Access variables it is expected that the user will write the correct data quality value into this parameter on every call. For some systems only a couple of the available values may be relevant and in this case it is not necessary to use them all.
Returns
The result of the operation.
void UAServer_Callback_write ( uint32_t  node_handle,
UA_Value_type_t  value_type,
UA_Status_t  status_code,
uint32_t  max_array_length,
uintptr_t  write_context 
)

Function provided by host to enable library to write values

The library requires the ability to write values from the host system in order to operate. This ability is provided by this function which must be implemented by the host system. This function is called by the library and the implemented function must call UA_Perform_write() in order to perform the actual write operation.

Parameters
[in]node_handleA unique identifier that the host can use to efficiently look up the value.
[in]value_typeIn order to keep the API lean, this function returns the variable to the library via a non type safe void pointer. The value_type parameter provides run-time type safety by specifying the data type the library expects for the value attribute of the node and allowing the host to verify this against the node handle provided by the library.
[in]status_codeThe status_code for the value written by the client.
[in]max_array_lengthSimilar to the value_type parameter, the max_array_length parameter facilitates run-time type safety by specifying the max array length the library expects for the provided pointer allowing the host to verify this against the node handle provided by the library.
[in]write_contextA pointer to an opaque data structure providing context to the pending write operation. The user must pass this pointer to UA_Perform_write().
UA_Status_t UAServer_Perform_write ( uintptr_t  write_context,
UA_Value_t  data_value,
int64_t *  source_timestamp,
bool_t  completes_asynchronously,
uint32_t *  new_length_of_array 
)

Performs a write operation

The host calls this function from UA_Write_callback() to perform a write on the requested node.

Parameters
[in]write_contextA pointer to an opaque data structure providing context to the pending write operation. The user must pass this pointer to UA_Perform_write().
[in]data_valueA pointer to the value required to be written by the library or 0 if the input parameters failed verification or the value is not writable. The value would not be writable if the host system's connection to the underlying data source was unavailable. In this case the host may decide to simply provide the most recent cached value (with a corresponding old timestamp) or may provide 0 in order to indicate that the data cannot be written.
[in]source_timestampThe timestamp for the value when written by the client. This may be modified by the library during the write if the client specified a source timestamp.
[in]completes_asynchronouslyIf the write to the underlying system completes asynchronously then this flag should be set. Alternatively if the write to the underlying system completes before the completion of UAServer_Write_callback() this flag should be cleared. The flag affects the result code the library returns to the OPC-UA Client. If the call succeeds and the flag is set the write operation level result is OpcUa_GoodCompletesAsynchronously. if the write succeeds and the flag is not set the write operation level result code is OpcUA_Good.
[out]new_length_of_arrayWhen a client writes to the value attribute of a node containing an array, the client can change the length of the array by writing a complete array that is shorter than the maximum array length. This parameter informs the host what the new array length is after the write in case this information is of interest.
Returns
The result of the operation.
void UAServer_Set_write_operation_level_result_code ( uintptr_t  write_context,
UA_Status_t  result_code 
)

Sets the result code of a write operation

The host can optionally call this function from UA_Write_callback() to revise the result code of a write operation. The Server SDK is a single threaded design and it is highly highly recommended that callbacks are completed promptly in order to reduce server latency and jitter. Where the application performs activities in the callbacks that delay the server by milliseconds server latency and jitter as experienced by the client can be poor. For this reason write operations that complete over a serial line, backplane or other slow medium should be buffered in the application and completed asynchronously. Where it is feasible and desirable to complete a write within the callback this call can be made after UAServer_Perform_write() and before returning from the callback in order to modify the result of the write operation, for example setting a bad operation level result due to a write failure.

Parameters
[in]write_contextA pointer to an opaque data structure providing context to the pending write operation. The user must pass this pointer to UA_Perform_write().
[in]result_codeIf the write to the underlying system completed synchronously after the UAServer_Perform_write() call (i.e. that call only buffered the data prior to the actual physical write) then this parameter specifies the actual write operation level result code. The default result code populated during UAServer_Perform_write() would have been OpcUa_Good.
void UAServer_Callback_monitored_item ( uint32_t  node_handle,
uint32_t  monitored_item_id,
UA_Mon_Item_Callback_Operation_t  operation,
uint64_t  sampling_interval_ms 
)

Function provided by host to enable library to indicate that a monitored item has been created for a variable node

Certain host systems may require notice from the library that a monitored item has been created or destroyed in order to maintain an internal cache of values or otherwise efficiently manage their read operations. This callback function enables a host to do so if it wishes but can be ignored if not required. Hosts must still be prepared to handle read callbacks for variables that are not being monitored (OPC-UA Read Service).

Parameters
[in]node_handleAn identifier that the host can use to efficiently look up the value.
[in]monitored_item_idA unique identifier in the SDK for the monitored item.
[in]operationIndicates if a monitored item has been created, modified (for example had its sample rate change) or destroyed.
[in]sampling_interval_msThe sampling interval in milliseconds.